
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    UserInfo: {},
    t_length: 0,
    content: '',
  },

  bindText(e) {
    var t_text = e.detail.value;
    this.setData({
      t_length: t_text.length,
      content: t_text
    })
  },

  submit() {
    let self = this
    const content = this.data.content
    if (content == '') {
      wx.showToast({ title: '请输入内容！', icon: 'none', duration: 3000 });
      return;
    }
    app.request({
      url: 'api/wechat/message',
      method: "GET",
      data: {
        content: content
      },
      success: function (res) {
        if (res.data.result) {
          wx.showModal({
            showCancel: false,
            content: '发送成功！',
            success: (res) => {
              wx.switchTab({
                url: '/pages/personalCenter1/index',
              })
            },
          })
        } else {
          wx.showToast({
            title: '请稍后重试！',
            icon: 'none'
          })
        }
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    app.editTabbar();
  },
  onShow: function () {
    let self = this
    app.request({
      url: 'api/wechat/getUserInfo',
      method: "GET",
      success: function (res) {
        self.setData({
          UserInfo: res.data.info
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})